<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"      
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:ezcomp="http://java.sun.com/jsf/composite/ezcomp">

    <ui:composition template="default_layout_with_menu.xhtml">
        <ui:define name="titulo-pagina">Menu do Sistema</ui:define>
        <ui:define name="content">
            <p:messages id="messages"/>

            <p:focus for="#{editMenuJsfBean.componenteComFoco}"/>

            <p:menuButton value="Novo item de Menu">
                <p:menuitem value="Como item filho" update="@form" process="@this" actionListener="#{editMenuJsfBean.novoItemFilho}" />
                <p:menuitem value="No mesmo nível" update="@form" process="@this" actionListener="#{editMenuJsfBean.novoItemIrmao}"/>
            </p:menuButton>
            <p:commandButton value="Excluir item de menu" ajax="true" image="excluir" update="messages,menu" process="@this"
                             onclick="return(confirm('#{msg.confirm_del}'))" immediate="true"
                             actionListener="#{editMenuJsfBean.excluiItemMenu}"/>

            <p:layout style="width:680px;height:400px;" id="pnl1">
                <p:layoutUnit position="left" width="290" resizable="true" minWidth="50">
                    <p:panel header="Menu do Sistema">
                        <p:tree id="menu" value="#{editMenuJsfBean.raizMenu}" var="node" update="panelForm,messages" nodeSelectListener="#{editMenuJsfBean.onItemMenuSelect}"
                                selectionMode="single" selection="#{editMenuJsfBean.menuItemSelecionado}">
                            <p:treeNode>
                                <h:outputText value="#{node}" />
                            </p:treeNode>
                        </p:tree>
                    </p:panel>
                </p:layoutUnit>

                <p:layoutUnit position="center">

                    <p:panel header="Item de menu" widgetVar="pnl1" id="panelForm">
                        <h:panelGrid columns="2">
                            <h:outputLabel id="recurso_lbl" value="Página:" for="recurso" />
                            <h:selectOneMenu id="recurso" value="#{editMenuJsfBean.menu.recurso}" converter="sec" >
                                <f:selectItem />
                                <f:selectItems value="#{editMenuJsfBean.listPaginas}" var="p" itemLabel="#{p}" itemValue="#{p}"/>
                            </h:selectOneMenu>                            

                            <h:outputLabel id="label_lbl" value="Label:" for="label" />
                            <h:inputText id="label" value="#{editMenuJsfBean.menu.label}" size="40"/>                            

                            <h:outputLabel id="icone_lbl" value="Ícone:" for="icone" />
                            <h:inputText id="icone" value="#{editMenuJsfBean.menu.icone}" size="40"/>
                            

                            <h:outputLabel/>
                            <h:panelGrid columns="2">
                                <p:commandButton value="Salvar" action="#{editMenuJsfBean.salvaItemMenu}" styleClass="botaoForm" process="panelForm" update="@form"/>
                                <p:commandButton value="Cancelar" action="#{editMenuJsfBean.cancelar}" styleClass="botaoForm" process="@this" update="@form"/>
                            </h:panelGrid>
                        </h:panelGrid>
                    </p:panel>

                </p:layoutUnit>
            </p:layout>




        </ui:define>
    </ui:composition>

</html>

